﻿//        Another Demo from Andy L. & MissedMemo.com
// Borrow whatever code seems useful - just don't try to hold
// me responsible for any ill effects. My demos sometimes use
// licensed images which CANNOT legally be copied and reused.

using System;
using System.Windows.Data;

using MissedMemo.MeatAndCheeseDisc.OrderMonitorService.OrderProcessing;
using MissedMemo.MeatAndCheeseDisc.UIHelperClasses;


namespace MissedMemo.MeatAndCheeseDisc.OrderMonitor
{
    public class ElapsedTimeToBorderWidthConverter : IValueConverter
    {
        public double OrderOnScheduleWidth { get; set; }
        public double OrderOnScheduleSelectedWidth { get; set; }
        public double OrderScheduleWarningWidth { get; set; }

        
        public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            bool isSelected = System.Convert.ToBoolean( parameter );
            double width = isSelected ? OrderOnScheduleSelectedWidth : OrderOnScheduleWidth;

            TimeSpan elapsedTime = (TimeSpan)value;

            if( elapsedTime != null )
            {
                if( elapsedTime > OrderTimer.ScheduleWarningThreshold )
                    width = OrderScheduleWarningWidth;
            }

            return width;
        }


        public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            throw new NotImplementedException();
        }
    }
}
